from django.db import models

class UserGroup(models.Model):
    title = models.CharField(verbose_name='组名称',max_length=32)

    def __str__(self):
        return self.title


class Role(models.Model):
    name= models.CharField(verbose_name='角色名称',max_length=32)
    def __str__(self):
        return self.name

class UserInfo(models.Model):

    group = models.ForeignKey(verbose_name='用户组',to=UserGroup,null=True,blank=True)
    name = models.CharField(verbose_name='用户名',max_length=32)
    nickname =  models.CharField(verbose_name='昵称',max_length=32,null=True,blank=True)
    email = models.EmailField(verbose_name='邮箱',max_length=32)

    ctime = models.DateTimeField(verbose_name='创建时间',null=True,blank=True)

    roles = models.ManyToManyField(verbose_name='角色',to=Role)

    def __str__(self):
        return self.name